(function ($) {
	var pageType='',statusKey='',detailPageType=''
	var methodName = '', nurseid = '',perId='',sourceData = []
	$.init();
	$.plusReady(function() {
		baseSetup();
	})
	if (!mui.os.plus) {
		baseSetup()
	}
	function getListData(){
		var pdict = {'parr':nurseid,nurseid:nurseid,"start":0,"limit":''}
		if (pageType=='专科履历') {
			pdict['parr'] = '^^^^^^'+perId
		}else if (pageType=='晋级履历' || pageType == '学习履历') {
			pdict['parr'] = perId
		}
		var paramDict = {'method':methodName,'params':JSON.stringify(pdict),'type':'RecQuery'}
		//console.log(JSON.stringify(pdict))
		$.DHCWebService(paramDict, function(result) {
			//console.log(JSON.stringify(result))
			if (result.msgcode != '1') {
				showNullTip(result.msg)
				return
			}
			sourceData = result['data']
			updateUI(result['data']);
		}, function(errorStr) {
			showNullTip(errorStr)
		});
	}
	
	function baseSetup(){
		$('.mui-scroll-wrapper').scroll({
			bounce: true,
			indicators: false, //是否显示滚动条
		});
		var perInfo = app.getState()
		nurseid = perInfo['loginID']
		perId = perInfo['loginPerID']
		var self = plus.webview.currentWebview()
		pageType = self.title
		$('.mui-title')[0].innerHTML = self.title
		mui('#UL').on('tap','li',openDetailPage) 
		getPageData();
		getListData()
	}
	function updateUI(dataArr){
		var innerHtml = ''
		for (var i = 0; i < dataArr.length;i++) {
			innerHtml += getOneLiHtml(dataArr[i],i)
		}
		$('#UL')[0].innerHTML = innerHtml;
		if (innerHtml == '') {
			showNullTip('暂无数据')
		}else{
			hideNullTip()
		}
	}
	
	function getOneLiHtml(dict,index){
		//专科发展 Y:提交 A:护理部审核 B:驳回 H:护士长审核
		var status = dict[statusKey]
		if (status != '审核' && status != '已审核' && status != '护理部已审核') {
			return ''
		}
		
		var html = ''
		switch (pageType){
			case '晋级履历':
				html = '<li id="'+index+'-li" class="mui-table-view-cell"><a class="mui-navigate-right">'+
					'<span>'+dict['nurLevel']+'履历</span>'+
					'<span class="mui-badge mui-badge-inverted">'+dict['levelDate']+'</span></a></li>'
				break
			case '科研履历':
				html = '<li id="'+index+'-li" class="mui-table-view-cell"><a class="mui-navigate-right">'+
					'<span>'+dict['awardTitle']+'</span>'+
					'<span class="mui-badge mui-badge-inverted">'+dict['awardDate']+'</span></a></li>'
				break;
			case '学习履历':
				html = '<li id="'+index+'-li" class="mui-table-view-cell"><a class="mui-navigate-right">'+
					'<span>'+dict['eduAcademic']+'</span>'+
					'<span class="mui-badge mui-badge-inverted">'+dict['eduDegreeDate']+'</span></a></li>'
				break;
			case '专科履历':
				html = '<li id="'+index+'-li" class="mui-table-view-cell"><a class="mui-navigate-right">'+
					'<span>'+dict['SpecialTypeDesc']+'</span>'+
					'<span class="mui-badge mui-badge-inverted">'+dict['SpecialAuthDate']+'</span></a></li>'
				break;
			default:
				break;
		}
		return html
	}
	
	function getPageData(){
		statusKey = 'status'
		switch (pageType){
			case '晋级履历':
				methodName = 'web.INMPersonComm:FindLevelList'
				detailPageType = '层级备案'
				break
			case '科研履历':
				methodName = 'web.INMPerSubComm:FindAwardList'
				statusKey = 'awardStatus'
				detailPageType = '科研履历'
				break;
			case '学习履历':
				methodName = 'web.INMPersonComm:FindEduList'
				detailPageType = '教育信息备案'
				break
			case '专科履历':
				methodName = 'web.INMSpecialComm:FindSpecialList'
				statusKey = 'SpecialStatusDesc'
				detailPageType = '专科发展备案'
				break
			default:
				break;
		}
	}
	function openDetailPage(){
		if (detailPageType == '') {
			return
		}
		var index = parseInt(this.id)
		var url = '../WKPlatformPages/apply-stander/applyDetail.html'
		var webview = plus.webview.create(url, 'applyDetail', {
			background: '#fff',
			statusbar: {
				background: '#fff'
			}
		}, {pageType:detailPageType,data:sourceData[index]});
		webview.show();
		//webview.addEventListener('close',resetStatusBar)
	}
	function showNullTip(msg){
		mui('.nullData')[0].style.display = 'block';
		mui('.nullTip')[0].innerHTML = msg
	}
	
	function hideNullTip(){
		mui('.nullData')[0].style.display = 'none';
	}
})(mui)
/*
 科研履历  获奖科研
	{"awardResult":"测试成果","awardTitle":"测试名称","awardScore":"","awardDate":"2021","awardRank":"",
	"awardStatus":"保存","statuscode":"N","awardRowID":"1","awardPatent":"","awardPatType":"","awardThesis":"",
	"awardPublic":"","awardPage":"","AwardType":"","AwardName":""}
学习履历  教育信息
	{"eduStDate":"2010-09-01","eduEndDate":"2014-06-30","eduSchool":"海南医学院","eduAcademic":"本科","eduDegree":"学士",
	"eduRowID":"3","eduProfession":"妇幼保健","eduRadio":"全日制","eduDegreeDate":"2014-06-30","eduAcadeType":"第一学历",
	"status":"驳回","eduFile":""}
专科履历 专科发展
	{"SpecialPer":"1","SpecialPerName":"高淑红","SpecialType":"66__1","SpecialTypeDesc":"手术专科证书",
	"SpecialAuth":"67__1","SpecialAuthDesc":"协和医院","SpecialAuthDate":"2023-04-18","SpecialCertificate":"",
	"SpecialStatus":"A","SpecialStatusDesc":"审核","Creator":"0","CreatorName":"管理员","CreateDate":"2023-04-18",
	"CreateTime":"17:33:57","Auditor":"0","AuditorName":"管理员","AuditDate":"2023-04-18","AuditTime":"17:34:05",
	"AuditOpinion":"","SpecialNurType":"26__1","SpecialNurTypeDesc":"ICU专科护士","rw":"16","Per":"1",
	"PerName":"高淑红","PerLevel":"N2","PerPost":"","PerHire":"","PerCurWard":"护理部","PerStatus":"在职"}
*/